﻿using System.ComponentModel;
using System.Diagnostics.Contracts;

namespace Office.Spreadsheet.UI
{
    static class WeakEventHelper
    {
        internal static void AddWeakPropertyChanged(INotifyPropertyChanged owner, PropertyChangedEventHandler value)
        {
            Contract.Requires(value != null);
            INotifyPropertyChanged nic = owner;
            PropertyChangedEventHandler weakEvent = EventHandlerHelper.MakeWeakPropertyChanged(value, v => nic.PropertyChanged -= v);
            nic.PropertyChanged += weakEvent;
        }
    }
}
